// HandTrackingBackgroundSubstraction.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "HandTrack.h"
#include <opencv2/core/core.hpp>
bool gotBB = false;
Rect box; // tracking object
bool drawing_box = false;

int main(int argc, char* argv[])
{
	namedWindow("img1", CV_WINDOW_KEEPRATIO);
	bool use_preset_colors = false;
	HandTrack ht;
	bool quit = false;
	printf("start hand tracking...\n");
	printf("Initial Tracking Box = x:%d y:%d h:%d w:%d\n", box.x, box.y, box.width, box.height);
	destroyWindow("img1");

	bool isTrained = false;

	bool isComposed = false;
	while(!isTrained)
	{
		if(ht.videoFrameCapture())
		{
			ht.updateModel();
			if(ht.isCodeBookInitialized)
			{
				ht.update();
				ht.drawMask();
			}		
			ht.draw_frame();
		}
		char c = cvWaitKey(20);
		if(c==27 || c == 'q' || c == 'Q')
		{	
			isTrained = true; 
		}
		else
		{
			ht.updateCodeBookValues(c);		
		}
	}

	return 0;
}

